﻿using System;
using System.Reactive.Linq;
using System.Windows;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;

namespace Wulong.Phone.Dianping.Views
{
    public partial class GroupOnItemView
    {
        public GroupOnItemView()
        {
            InitializeComponent();
            
            busyIndicator.Visibility = Visibility.Visible;
            progressBar.IsIndeterminate = true;
            Observable.FromEventPattern<NavigatingEventArgs>(
                h => browser.Navigating += h,
                h => browser.Navigating -= h
                )
                .ObserveOnDispatcher()
                .Subscribe(args =>
                               {
                                   busyIndicator.Visibility = Visibility.Visible;
                                   progressBar.IsIndeterminate = true;
                               });
            Observable.FromEventPattern<NavigationEventArgs>(
                h => browser.Navigated += h,
                h => browser.Navigated -= h
                )
                .ObserveOnDispatcher()
                .Subscribe(args=>
                               {
                                   busyIndicator.Visibility = Visibility.Collapsed;
                                   progressBar.IsIndeterminate = false;
                               });
        }
    }
}
